package com.edu.app.mapper.core;

import com.edu.app.bean.core.SysActivity;
import com.edu.app.bean.core.SysUser;
import com.edu.app.util.AppBaseMapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface SysUserMapper extends AppBaseMapper<SysUser> {
    //采用通用Mapper，也可以在这里添加自己的Mapper
    @Select("SELECT * FROM S_USER WHERE USERNAME=#{userName}")
    SysUser getUserByName(String userName);

    @Select("SELECT t3.* FROM S_USER t1 INNER JOIN S_USER_ACTIVITY t2 on t1.ID = t2.USER_ID INNER " +
            "JOIN S_ACTIVITY t3 on t2.ACTIVITY_ID = t3.ID " +
            "WHERE t1.username = #{username};")
    List<SysActivity> getActivityListByUserName(String username);

    @Select("select t1.* from s_user t1 " +
            "inner join s_user_role t2 on t1.id = t2.user_id " +
            "inner join s_role t3 on t3.id = t2.role_id " +
            "where t3.role_name = 'consultant' and t1.status = 1")
    List<SysUser> getUserListByType(@Param("roleName") String roleName, @Param("status") Integer status);

    @Select("select * from s_user where wx_open_id is not null")
    List<SysUser> getUserListForWxNotifications();
}
